﻿Friend Class FeaturesRepository

    Private m_repository As IFeaturesRepository

    Public Sub New(repository As IFeaturesRepository)
        m_repository = repository
    End Sub

    Public Sub LoadFeatures()
        Dim loadedFeatures As Dictionary(Of String, Boolean)
        Try
            loadedFeatures = m_repository.LoadFeatures()
        Catch ex As Exception
            Throw New LoadFromRepositoryException(ex)
        End Try
        Features.LoadSnapshot(loadedFeatures)
    End Sub

    Public Sub SaveFeaturesState()
        Dim snapshot = Features.GetSnapshot()
        Try
            m_repository.SaveFeatures(snapshot)
        Catch ex As Exception
            Throw New SaveToRepositoryException(ex)
        End Try
    End Sub

End Class
